function grin(a) {
    var c;
    a = " " + a + " ";
    if (document.getElementById("comment") && "textarea" == document.getElementById("comment").type) c = document.getElementById("comment");
    else return !1;
    if (document.selection) c.focus(), sel = document.selection.createRange(), sel.text = a, c.focus();
    else if (c.selectionStart || "0" == c.selectionStart) {
        var b = c.selectionEnd,
            d = b;
        c.value = c.value.substring(0, c.selectionStart) + a + c.value.substring(b, c.value.length);
        d += a.length;
        c.focus();
        c.selectionStart = d;
        c.selectionEnd = d
    } else c.value += a, c.focus()
}

function AutoScroll(a) {
    $(a).find("ul:first").animate({
        marginTop: "-10px"
    }, 300, function () {
        $(this).css({
            marginTop: "0px"
        }).find("li:first").appendTo(this)
    })
}
$(function () {
    $t = setInterval('AutoScroll(".bulletin")', 3E3);
    $(".bulletin").hover(function () {
        clearInterval($t)
    }, function () {
        $t = setInterval('AutoScroll(".bulletin")', 5E3)
    })
});
$(document).ready(function () {
    $("#commentform").submit(function () {
        var a = $("#commentform").serialize();
        $("#comment").attr("disabled", "disabled");
        $(".ajaxloading").show();
        $(".tj").hide();
        $.post($("#commentform").attr("action"), a, function (c) {
            var b = /<div class=\"main\">[\r\n]*<p>(.*?)<\/p>/i;
            b.test(c) ? ($(".error").html(c.match(b)[1]).show().fadeOut(2500), $(".ajaxloading").hide(), $(".tj").show()) : (b = $("input[name=pid]").val(), cancelReply(), $("[name=comment]").val(""), $(".commentlist").html($(c).find(".commentlist").html()), 0 != b ? (c = window.opera ? "CSS1Compat" == document.compatMode ? $("html") : $("body") : $("html,body"), c.animate({
                scrollTop: $("#comment-" + b).offset().top - 20
            }, "normal", function () {
                $(".ajaxloading").hide();
                $(".tj").show()
            })) : (c = window.opera ? "CSS1Compat" == document.compatMode ? $("html") : $("body") : $("html,body"), c.animate({
                scrollTop: $(".commentlist").offset().top - 20
            }, "normal", function () {
                $(".ajaxloading").hide();
                $(".tj").show()
            })));
            $("#wrapper a,#wrapper div,#wrapper2 div,#wrapper li,h3,h4,img,.bulletin a,.social a,#wenkmPlayer i,#wenkmPlayer div").each(function () {
                if (this.title) {
                    var b = this.title;
                    $(this).mouseover(function (c) {
                        this.title = "";
                        $("body").append('<div id="tooltip">' + b + "</div>");
                        $("#tooltip").css({
                            left: c.pageX - 15 + "px",
                            top: c.pageY + 30 + "px",
                            opacity: "0.8"
                        }).fadeIn(1)
                    }).mouseout(function () {
                        this.title = b;
                        $("#tooltip").remove()
                    }).mousemove(function (b) {
                        $("#tooltip").css({
                            left: b.pageX - 15 + "px",
                            top: b.pageY + 30 + "px"
                        })
                    })
                }
            });
            $("#comment").attr("disabled", !1)
        });
        return !1
    })
});
$(function () {
    $("#wrapper a,#wrapper div,#wrapper2 div,#wrapper li,h3,h4,img,.bulletin a,.social a,#wenkmPlayer i,#wenkmPlayer div").each(function () {
        if (this.title) {
            var a = this.title;
            $(this).mouseover(function (c) {
                this.title = "";
                $("body").append('<div id="tooltip">' + a + "</div>");
                $("#tooltip").css({
                    left: c.pageX - 15 + "px",
                    top: c.pageY + 30 + "px",
                    opacity: "0.8"
                }).fadeIn(250)
            }).mouseout(function () {
                this.title = a;
                $("#tooltip").remove()
            }).mousemove(function (c) {
                $("#tooltip").css({
                    left: c.pageX - 15 + "px",
                    top: c.pageY + 30 + "px"
                })
            })
        }
    })
});
(function (a) {
    a.fn.WIT_SetTab = function (c) {
        function b(b) {
            c.Field.filter(":visible").fadeOut(c.OutTime, function () {
                c.Field.eq(b).fadeIn(c.InTime).siblings().hide()
            });
            c.Nav.eq(b).addClass(c.CurCls).siblings().removeClass(c.CurCls)
        }

        c = a.extend({
            Nav: null,
            Field: null,
            K: 0,
            CurCls: "cur",
            Auto: !1,
            AutoTime: 5E3,
            OutTime: 100,
            InTime: 150,
            CrossTime: 60
        }, c || {});
        var d = null,
            e = !1,
            g = null;
        b(c.K);
        c.Nav.hover(function () {
            c.K = c.Nav.index(this);
            c.Auto && clearInterval(g);
            e = a(this).hasClass(c.CurCls);
            d = setTimeout(function () {
                e || b(c.K)
            }, c.CrossTime)
        }, function () {
            clearTimeout(d);
            c.Ajax && c.AjaxFun();
            c.Auto && (g = setInterval(function () {
                c.K++;
                b(c.K);
                c.K == c.Field.size() && (b(0), c.K = 0)
            }, c.AutoTime))
        }).eq(0).trigger("mouseleave")
    }
})(jQuery);
$(function () {
    $(document).WIT_SetTab({
        Nav: $("#J_setTabANav>ul>li"),
        Field: $("#J_setTabABox>div>ul"),
        CurCls: "hover"
    });
    $(document).WIT_SetTab({
        Nav: $("#J_setTabBNav>ul>li"),
        Field: $("#J_setTabBBox>div>ul"),
        Auto: !0,
        CurCls: "hover"
    })
});
jQuery(document).ready(function () {
    $(".go-comment").click(function () {
        $body.animate({
            scrollTop: $("#comment-post").offset().top - 200
        }, 1002);
        return !1
    })
});
jQuery(document).ready(function () {
    $(".link-back2top").click(function () {
        $body.animate({
            scrollTop: $("#header").offset().top - 200
        }, 1E3);
        return !1
    })
});
$(document).ready(function () {
    var a = 13;
    $(".size").click(function () {
        13 == a ? (a += 3, $(".post-context").css("font-size", a + "px"), $(".size").css({
            "box-shadow": "inset 0px 0px 10px #cccccc",
            "font-weight": "bold"
        })) : 16 == a ? (a -= 4, $(".post-context").css("font-size", a + "px"), $(".size").css({
            "box-shadow": "inset 0px 0px 10px #cccccc",
            "font-weight": "bold"
        })) : (a = 13, $(".post-context").css("font-size", a + "px"), $(".size").css({
            "box-shadow": "none",
            "font-weight": "normal"
        }))
    })
});

/**
 * 文章详情页，修改字号
 * @param a
 */
function size(a) {
    a.innerHTML = "A" == a.innerHTML ? "A+" : "A+" == a.innerHTML ? "A-" : "A"
}
/**
 * 切换全屏
 */
function fullscreen() {
    if ($(".fullscreen i").hasClass("icon-redo")) {
        $("#sidebar").css("display", "none");
        $("#content").css("border-right", "0px dashed #ccc");
        $("#content").animate({
            width: "100%"
        }, "slow");
        $(".fullscreen i").removeClass("icon-redo");
        $(".fullscreen i").addClass("icon-undo");
    }
    else {
        $("#sidebar").css("display", "block");
        $("#content").css("border-right", "1px dashed #ccc");
        $("#content").animate({
            width: $('#container').width() - 280
        }, "slow");
        $(".fullscreen i").removeClass("icon-undo");
        $(".fullscreen i").addClass("icon-redo");
    }
}
$(document).ready(function () {
    $(".post-title a").hover(function () {
        $(this).stop().animate({
            marginLeft: "4px"
        }, "fast")
    }, function () {
        $(this).stop().animate({
            marginLeft: "0px"
        }, "fast")
    })
});
$(document).ready(function () {
    $("#nav .catbtn").hover(function () {
        $(this).children(".catbtn ul").slideDown(100)
    }, function () {
        $(this).children(".catbtn ul").stop().slideUp(100)
    })
});
jQuery(document).ready(function () {
    $(".ssearch input[type='text'],.hsearch input[type='text']").focus(function () {
        $(this).stop(!0, !1).animate({
            width: "200px"
        }, "fast")
    }).blur(function () {
        $(this).animate({
            width: "160px"
        }, "fast")
    })
});
jQuery(document).ready(function () {
    function a(b, c, a) {
        if (document.selection) b.focus(), sel = document.selection.createRange(), a ? sel.text = c + sel.text + a : sel.text = c, b.focus();
        else if (b.selectionStart || "0" == b.selectionStart) {
            var f = b.selectionStart,
                h = b.selectionEnd,
                k = h;
            a ? b.value = b.value.substring(0, f) + c + b.value.substring(f, h) + a + b.value.substring(h, b.value.length) : b.value = b.value.substring(0, f) + c + b.value.substring(h, b.value.length);
            a ? k += c.length + a.length : k += c.length - h + f;
            f == h && a && (k -= a.length);
            b.focus();
            b.selectionStart = k;
            b.selectionEnd = k
        } else b.value += c + a, b.focus()
    }

    var c = (new Date).toLocaleTimeString(),
        b = document.getElementById("comment") || 0;
    window.SIMPALED = {};
    window.SIMPALED.Editor = {
        strong: function () {
            a(b, "[strong]", "[/strong]")
        },
        em: function () {
            a(b, "[em]", "[/em]")
        },
        del: function () {
            a(b, "[del]", "[/del]")
        },
        url: function () {
            a(b, "[url]", "[/url]")
        },
        quote: function () {
            a(b, "[blockquote]", "[/blockquote]")
        },
        underline: function () {
            a(b, "[u]", "[/u]")
        },
        qiandao: function () {
            a(b, "[blockquote]\u7b7e\u5230\u6210\u529f\uff01\u7b7e\u5230\u65f6\u95f4\uff1a" + c, "\uff0c\u6bcf\u65e5\u6253\u5361\uff0c\u751f\u6d3b\u66f4\u7cbe\u5f69\u54e6~[/blockquote]")
        },
        qq: function () {
            a(b, "[qq]", "[/qq]")
        },
        code: function () {
            a(b, "[code]", "[/code]")
        },
        good: function () {
            a(b, "[blockquote][F1] \u597d\u7f9e\u5c04\uff0c\u6587\u7ae0\u771f\u7684\u597d\u8d5e\u554a\uff0c\u9876\u535a\u4e3b\uff01[/blockquote]")
        },
        bad: function () {
            a(b, "[blockquote][F14] \u6709\u70b9\u770b\u4e0d\u61c2\u54e6\uff0c\u5e0c\u671b\u4e0b\u6b21\u5199\u7684\u7b80\u5355\u6613\u61c2\u4e00\u70b9\uff01[/blockquote]")
        }
    }
});

function embedImage() {
    var a = prompt("\u8bf7\u8f93\u5165\u56fe\u7247\u7684 URL \u5730\u5740\uff08\u7981\u6b62\u4e0d\u826f+\u65e0\u804a\u56fe\u7247\uff09:", "undefined/undefined.undefined");
    a && (document.getElementById("comment").value = document.getElementById("comment").value + "[img]" + a + "[/img]")
}

function embedSmiley() {
    "none" == $(".smile").css("display") ? $(".smile").show() : $(".smile").hide()
}
jQuery(document).ready(function () {
    $(".smile").click(function () {
        $(".smile").hide()
    })
});
jQuery(document).ready(function () {
    $("#comment").bind("focus keyup input paste", function () {
        $("#num").text($(this).attr("value").length)
    })
});

function cancelReply() {
    var a = document.getElementById("comment-place"),
        c = document.getElementById("comment-post");
    document.getElementById("comment-pid").value = 0;
    $(".reply a").css({
        display: ""
    });
    document.getElementById("cancel-reply").style.display = "none";
    a.appendChild(c);
    $("#comment-place").animate({
        height: "330px"
    }, 300)
}

function b2top(a, c, b) {
    if (10 >= c && 0 <= c) {
        var d = 100 * c;
        $(a).css({
            backgroundPosition: "0 -" + d + "px"
        });
        setTimeout("b2top('" + a + "'," + (b ? c + 1 : c - 1) + "," + b + ")", 50)
    }
}
$(document).ready(function () {
    $body = window.opera ? "CSS1Compat" == document.compatMode ? $("html") : $("body") : $("html,body");
    $("a[href*=#]").click(function () {
        if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) {
            var a = $(this.hash),
                a = a.length && a || $("[name=" + this.hash.slice(1) + "]");
            if (a.length) return a = a.offset().top, $("html,body").animate({
                scrollTop: a
            }), !1
        }
    });
    navigator.userAgent.match(/(iPhone|iPod|Ipad|Android|ios)/i) ? ($(window).scroll(function () {
        var a = $(document).scrollTop(),
            c = $(window).height();
        10 >= a ? $("#totop").hide() : ($("#totop").show(), "undefined" != typeof $.browser && 6 == $.browser.version && $("#totop").css("top", c + a - 110 + "px"))
    }), $(document).on("click", "#totop", function () {
        $("html,body").animate({
            scrollTop: 0
        }, 500);
        $(this).animate({
            top: "-80px"
        }, 500, function () {
            $("#totop").css("top", "")
        })
    })) : ($(window).scroll(function () {
        200 < $(this).scrollTop() ? $(".backtop,.link-back2top").fadeIn() : $(".backtop,.link-back2top").fadeOut()
    }), $(".backtop").hover(function () {
        b2top(".backtop", 0, !0)
    }, function () {
        b2top(".backtop", 3)
    }).click(function () {
        $("body,html").animate({
            scrollTop: 0
        }, 600, function () {
        });
        b2top(".backtop", 3)
    }))
});
$(document).ready(function () {
    $(".archives").find("ul").hide();
    $(".archives").find("ul:first,ul:eq(1),ul:eq(2),ul:eq(3),ul:eq(4),ul:eq(5),ul:eq(6),ul:eq(7),ul:eq(8),ul:eq(9),ul:eq(10),ul:eq(11),ul:eq(12),ul:eq(13),ul:eq(14),ul:eq(15)").show();
    $(".archives h4").click(function () {
        $(this).next("ul").slideToggle("fast")
    })
});
$(document).ready(function () {
    $("#newlog li a,#randlog li a,#hotlog li a,#record li a,#blogsort li a,.tab_box li a,#link li a").hover(function () {
        $(this).stop().animate({
            marginLeft: "4px"
        }, "fast")
    }, function () {
        $(this).stop().animate({
            marginLeft: "0px"
        }, "fast")
    })
});
$(document).ready(function () {
    $(".open-nav,.close-nav").click(function () {
        $("#mmenu").hasClass("has-opened") ? $("#mmenu").removeClass("has-opened") : $("#mmenu").addClass("has-opened")
    })
});
$(document).ready(function () {
    $("#mmenu .catbtn ul").hide();
    $("#mmenu .catbtnx").click(function () {
        $(this).next("ul").slideToggle("fast")
    })
});
/**
 * 双击回到顶部
 */
$(document).ready(function (a) {
    a(function () {
        a("body").dblclick(function () {
            var c = a(window),
                b = c.scrollTop(),
                d = (b - 0) / 5,
                e = b,
                g = setInterval(function () {
                    0 >= (e - 0) * (b - 0) ? (clearInterval(g), b = e = 0, c.scrollTop(0)) : (e = b, c.scrollTop(b -= d))
                }, 20),
                f = a("#top").children(":first");
            f.stop().show().animate({}, function () {
                a(this).css({})
            });
            f.parent().append(f)
        });
        a("#top").dblclick(function (c) {
            c.stopPropagation()
        })
    })
});

$(document).ready(function () {
    var a = $(".search input"),
        c = $(".search button"),
        b = $(".search .result"),
        d = $(".search .result div");
    a.focus(function () {
        "Search..." == a.val() && a.val("")
    });
    a.blur(function () {
        "" == a.val() && (a.val("Search..."), c.stop().fadeOut())
    });
    a.keydown(function () {
        clearTimeout("t")
    }).keypress(function () {
        clearTimeout("t")
    });
    a.keyup(function () {
        0 < a.val().length ? (c.fadeIn(), 1 < a.val().length && (c.addClass("load"), t = setTimeout(function () {
            d.load("/search_result.php?k=" + a.val(), function () {
                b.fadeIn();
                b.find("h2 span").html(a.val());
                c.removeClass("load")
            })
        }, 1E3))) : (c.stop().fadeOut(), b.stop().fadeOut())
    });
    c.click(function () {
        c.stop().fadeOut();
        b.stop().fadeOut()
    });
    b.click(function () {
        b.stop().fadeOut()
    })
});